package com.zy.view.study;

import android.content.Context;
import android.graphics.Canvas;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import com.zy.zlog.ZLog;

public class DiyLinearLayout extends LinearLayout {
    private static final String TAG = "DiyLinearLayout";

    public DiyLinearLayout(@NonNull Context context) {
        super(context);
    }

    public DiyLinearLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public DiyLinearLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public DiyLinearLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        ZLog.d(TAG, "widthMeasureSpec:" + MeasureSpec.toString(widthMeasureSpec) + " heightMeasureSpec:" + MeasureSpec.toString(heightMeasureSpec));
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        ZLog.d(TAG, "onLayout s 测量宽高:[" + getMeasuredWidth() + "," + getMeasuredHeight() + "] 实际宽高[" + getWidth() + "," + getHeight() + "] " + "[" + left + "," + top + "," + right + "," + bottom + "]");
        //ZLog.d(TAG, "onLayout s 测量宽高:[" + getMeasuredWidth() + "," + getMeasuredHeight() + "] 实际宽高[" + getWidth() + "," + getHeight() + "]");
        //ZLog.d(TAG, "onLayout s :[" + left + "," + top + "," + right + "," + bottom + "]");
        super.onLayout(changed, left, top, right, bottom);
        ZLog.d(TAG, "onLayout e 测量宽高:[" + getMeasuredWidth() + "," + getMeasuredHeight() + "] 实际宽高[" + getWidth() + "," + getHeight() + "]");
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
    }
}
